package com.example.myapplication1;

import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

public class LocationDetailActivity extends AppCompatActivity {
    public static final String EXTRA_LOCATION_NAME = "location_name";
    private static final String TAG = "LocationDetailActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        try {
            super.onCreate(savedInstanceState);
            Log.d(TAG, "正在创建位置详情页面");
            setContentView(R.layout.activity_location_detail);
            
            String locationName = getIntent().getStringExtra(EXTRA_LOCATION_NAME);
            
            Toolbar toolbar = findViewById(R.id.toolbar);
            if (toolbar != null) {
                setSupportActionBar(toolbar);
                if (getSupportActionBar() != null) {
                    getSupportActionBar().setTitle(locationName);




                    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
                }
                toolbar.setNavigationOnClickListener(v -> finish());
            } else {
                Log.e(TAG, "找不到Toolbar");
            }
        } catch (Exception e) {
            Log.e(TAG, "创建位置详情页面时出错: " + e.getMessage());




            Toast.makeText(this, "页面加载失败", Toast.LENGTH_SHORT).show();
            finish();
        }
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.d(TAG, "位置详情页面已启动");
    }
} 